<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<html>
<head>
    <title>登录功能</title>

    <script type="text/javascript">

        var xmlHttp;
        function verify() {
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;
            console.log(password);
            //创建XMLHttpRequest对象
            if (window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();
            } else {//IE6
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }

            //服务器地址和数据
            var url = "usercheck.do?username=" + username + "&password=" + password
            //规定请求类型,URL 以及是否异步
            xmlHttp.open("GET", url, true);
            //将请求发送到服务器
            xmlHttp.send();
            //回调函数
            xmlHttp.onreadystatechange = function () {
                if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                    //给span 设置内容
                    document.getElementById("result").innerHTML = xmlHttp.responseText;
                }
            };
        }
    </script>
    <%
        if (request.getAttribute("aaa") == "567") {
    %>
    <script>
        alert("Hello word");
    </script>
    <%
            return;
        }
    %>
</head>
<body>
<fieldset>
    <h1>登录功能</h1>
    <form action="login.do" method="get">
        <table cellpadding="0" cellspacing="0" border="0"
               class="form_table">
            <tr>
                <td>
                    用户名：
                </td>
                <td>
                    <input type="text" class="user" name="username" id="username"/>
                    <span style="color: red;font-size: 24px" id="result">
                        ${login_failed}
                    </span>

                </td>
            </tr>
            <tr>
                <td>
                    密码：
                </td>
                <td>
                    <input type="text" class="password" name="password" id="password" onblur="verify()"/>
                </td>
            </tr>
        </table>
        <p>
            <input type="submit" class="button" value="登录">
            <%String msg = (String) request.getAttribute("login_faild"); %>
            <span style="color:red;font-size:25px"><%=(msg == null ? "" : msg)%></span>
        </p>
    </form>
</fieldset>
</body>
</html>